package week_three_day03.dom;


import java.io.FileInputStream;
import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

public class DomDemo01 {
	public static void main(String[] args) throws Exception {
		Document doc = new SAXBuilder(true).build(new FileInputStream("customer.xml"));
		Element root = doc.getRootElement();
		System.out.println("root:"+root.getName());
		List<Element> cs = root.getChildren();
		for(Element c:cs){
			String id = c.getAttribute("id").getValue();
			String name = c.getChild("name").getText();
			String age = c.getChild("age").getTextTrim();
			System.out.println(id+"\t"+name+"\t"+age);
		}
	}
}
